﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="html" indent="yes"/>
    <xsl:variable name="quote">&quot;</xsl:variable>

    <xsl:template match="doc">
      <html>
        <title>
          <xsl:text>Documentation of </xsl:text>
          <xsl:value-of select="translate(./assembly/node(),$quote,'')"/>
        </title>
      <body style="font-family:Arial">
        <xsl:apply-templates select="assembly"/>
        <xsl:apply-templates select="members" />
        <hr />
        <p>
          <b>
            <xsl:text>Copyright (c) 2010 Microsoft Corporation. All rights reserved.</xsl:text>
          </b>
        </p>
        <p>
          <xsl:text>THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
PARTICULAR PURPOSE.</xsl:text>
        </p>
      </body>
      </html>
    </xsl:template>

  <xsl:template match="assembly">
    <h1>
      <xsl:value-of select="translate(node(),$quote,'')"/>
    </h1>
    <xsl:if test="string-length(./summary)&gt;0" >
      <p>
        <xsl:value-of select="summary"/>
      </p>
    </xsl:if>
  </xsl:template>
  <xsl:template match="members">
    <xsl:for-each select="member">
      <xsl:sort select="@name"/>
      <p style="margin-left: 2em; line-height: 130%; margin-top:0; margin-bottom:0">
        <xsl:element name="a">
          <xsl:attribute name="href">
            <xsl:value-of select="concat('#',substring-after(substring-before(@name,'('),':'))" />
          </xsl:attribute>
          <xsl:value-of select="substring-after(substring-before(@name,'('),':')"/>
        </xsl:element>
      </p>
    </xsl:for-each>
    <xsl:apply-templates select="member" />
  </xsl:template>

  <xsl:template match="member">
    <hr/>
    <h2>
      <xsl:element name="a">
        <xsl:attribute name="name">
          <xsl:value-of select="concat('#',substring-after(substring-before(@name,'('),':'))" />
        </xsl:attribute>
        <xsl:value-of select="substring-after(substring-before(@name,'('),':')"/>
      </xsl:element>
    </h2>
    <p>
      <xsl:value-of select="./summary" />
    </p>
    <h3>
      <xsl:text>Parameters</xsl:text>
    </h3>
    <div style="margin-left:2 em">
    <table>
      <tr>
        <th style="text-align:left; border-bottom:1px solid #c0c0c0">
          <xsl:text>Name</xsl:text>
        </th>
        <th>
          <xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
        </th>
        <th style="text-align:left; border-bottom:1px solid #c0c0c0">
          <xsl:text>Description</xsl:text>
        </th>
      </tr>
      <xsl:apply-templates select="param" />
    </table>
    </div>
    <h3>
      <xsl:text>Returns</xsl:text>
    </h3>
    <p>
      <xsl:value-of select="./returns"/>
    </p>
    <xsl:if test="string-length(./remarks)&gt;0">
      <xsl:apply-templates select="remarks" />
    </xsl:if>
    <p>
      <xsl:text disable-output-escaping="yes">Found in&amp;nbsp;</xsl:text>
      <i>
      <xsl:value-of select="./module"/>
      </i>
    </p>
    <p>
      <xsl:element name="a">
        <xsl:attribute name="href">#</xsl:attribute>
        <xsl:text>Top of page</xsl:text>
      </xsl:element>
    </p>
  </xsl:template>
  
  <xsl:template match="param">
    <tr>
      <td style="text-align:left; vertical-align:top; padding-right:1 em">
        <b>
          <xsl:value-of select="@name"/>
        </b>
      </td>
      <td>
        <xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
      </td>
      <td style="text-align:left; vertical-align:top">
      <p>
        <xsl:value-of select="."/>
      </p>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="remarks">
    <h3>
      <xsl:text>Remarks</xsl:text>
    </h3>
    <xsl:value-of select="node()"/>
    <xsl:for-each select="p">
      <p>
        <xsl:value-of select="."/>
      </p>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
